package gui;

import java.awt.Color;
import javax.swing.JLabel;
import javax.swing.JPanel;
import world.Species;

public class NewSimWindow extends javax.swing.JFrame 
{
    Species[] sList;
    //In species list panel. Calls editSpecies() passing index when clicked.
    JPanel[] pnlSpeciesColor;
    //In species list panel. Calls editSpecies() passing index when clicked.
    JLabel[] lblSpeciesName;

    /**
     * Arguments
     * -Name
     * -Color
     * -life
     * -hunger
     * -sight radius
     * -attack power
     * -regen
     * -gestation
     * -attack cost
     * -move cost
     * -mate cost
     * -wait cost
     * -diet
     * Initializes new species with passed values and adds to internal list and displayed list
     */
//    void speciesAdded(String name, Color col, int health, int hunger, int sRad, 
//            int atkPow, int regen, int preg, int atkCost, int movCost, 
//            int mateCost, int waitCost, boolean diet, int movSp)
//    {
////        Species newbie = new Species(name, health, atkPow, regen, hunger, sRad,
////                preg, diet, movSp, mateCost, atkCost, movCost, waitCost,0 , col);
//        Species[] nList = new Species[sList.length+1];
//        for (int i = 0; i < sList.length; i++)
//        {
//            nList[i] = sList[i];
//        }
//        nList[sList.length] = newbie;
//        
//    }
    
    /**
     * Closes the window without saving.
     */
    void cancel() 
    {
        setVisible(false);
    }
    
    /**
     * Validates the items in the window. If valid, calls startSim in 
     * MainWindow passing species list, board size, veggie rate, 
     * and veggie content
     */
    void Start()
    {
        boolean errFound = false;
        if (sList.length < 1)
        {
            errFound = true;
//            pnlSpeciesList.setBackgroundColor
        }
    }
    
//    addSpecies()
//    Calls newSpecies() in MainWindow passing a reference to this window. Adds returned species to list.
//    editSpecies()
//    Arguments:
//    index of species to edit
//    Calls editSpecies() in MainWindow passing a reference to this window, and species to edit. Puts data for returned species in desired location.

    public NewSimWindow() {
        initComponents();
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        java.awt.GridBagConstraints gridBagConstraints;

        lblSizeX = new javax.swing.JLabel();
        txtSizeX = new javax.swing.JTextField();
        lblSizeY = new javax.swing.JLabel();
        txtSizeY = new javax.swing.JTextField();
        lblMutate = new javax.swing.JLabel();
        txtMutate = new javax.swing.JTextField();
        lblVeggieRate = new javax.swing.JLabel();
        txtVeggieRate = new javax.swing.JTextField();
        lblVeggieCont = new javax.swing.JLabel();
        txtVeggieCont = new javax.swing.JTextField();
        pnlSpeciesList = new javax.swing.JPanel();
        btnAddSpecies = new javax.swing.JButton();
        btnStart = new javax.swing.JButton();
        btnCancel = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        getContentPane().setLayout(new java.awt.GridBagLayout());

        lblSizeX.setText("X axis size:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_END;
        getContentPane().add(lblSizeX, gridBagConstraints);

        txtSizeX.setPreferredSize(new java.awt.Dimension(75, 20));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        getContentPane().add(txtSizeX, gridBagConstraints);

        lblSizeY.setText("Y axis size:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_END;
        getContentPane().add(lblSizeY, gridBagConstraints);

        txtSizeY.setPreferredSize(new java.awt.Dimension(75, 20));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        getContentPane().add(txtSizeY, gridBagConstraints);

        lblMutate.setText("Mutation Factor:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_END;
        getContentPane().add(lblMutate, gridBagConstraints);

        txtMutate.setPreferredSize(new java.awt.Dimension(75, 20));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        getContentPane().add(txtMutate, gridBagConstraints);

        lblVeggieRate.setText("Veggie Spawn Rate:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 3;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_END;
        getContentPane().add(lblVeggieRate, gridBagConstraints);

        txtVeggieRate.setPreferredSize(new java.awt.Dimension(75, 20));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 3;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        getContentPane().add(txtVeggieRate, gridBagConstraints);

        lblVeggieCont.setText("Veggie Content:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 4;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_END;
        getContentPane().add(lblVeggieCont, gridBagConstraints);

        txtVeggieCont.setPreferredSize(new java.awt.Dimension(75, 20));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 4;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        getContentPane().add(txtVeggieCont, gridBagConstraints);

        pnlSpeciesList.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        pnlSpeciesList.setPreferredSize(new java.awt.Dimension(150, 100));
        pnlSpeciesList.setLayout(new java.awt.GridBagLayout());
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridwidth = 2;
        gridBagConstraints.gridheight = 6;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.PAGE_START;
        getContentPane().add(pnlSpeciesList, gridBagConstraints);

        btnAddSpecies.setText("Add Species");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 6;
        gridBagConstraints.gridwidth = 2;
        getContentPane().add(btnAddSpecies, gridBagConstraints);

        btnStart.setText("Start");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 7;
        gridBagConstraints.gridwidth = 2;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_END;
        getContentPane().add(btnStart, gridBagConstraints);

        btnCancel.setText("Cancel");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 7;
        gridBagConstraints.gridwidth = 2;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START;
        getContentPane().add(btnCancel, gridBagConstraints);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnAddSpecies;
    private javax.swing.JButton btnCancel;
    private javax.swing.JButton btnStart;
    private javax.swing.JLabel lblMutate;
    private javax.swing.JLabel lblSizeX;
    private javax.swing.JLabel lblSizeY;
    private javax.swing.JLabel lblVeggieCont;
    private javax.swing.JLabel lblVeggieRate;
    private javax.swing.JPanel pnlSpeciesList;
    private javax.swing.JTextField txtMutate;
    private javax.swing.JTextField txtSizeX;
    private javax.swing.JTextField txtSizeY;
    private javax.swing.JTextField txtVeggieCont;
    private javax.swing.JTextField txtVeggieRate;
    // End of variables declaration//GEN-END:variables
}
